﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UtilZ.Dotnet.Ex.Communication.Net.Ftp
{
    /// <summary>
    /// ftp状态码响应
    /// </summary>
    internal class FtpCodeResponse : FtpResponseAbs
    {
        protected readonly string _message;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="code">ftp响应状态码</param>
        public FtpCodeResponse(short code)
            : base()
        {
            this._message = $"{code:D3} {FtpStatusCodes.GetNameByValue(code)}.".TrimEnd();
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="code">ftp响应状态码</param>
        /// <param name="message">消息</param>
        public FtpCodeResponse(short code, string message)
            : base()
        {
            this._message = $"{code:D3} {message}".TrimEnd();
        }


        protected override string GetMessage()
        {
            return this._message;
        }


        private static FtpCodeResponse _notImplementedCommandResponse = null;
        public static FtpCodeResponse NotImplementedCommandResponse
        {
            get
            {
                if (_notImplementedCommandResponse == null)
                {
                    _notImplementedCommandResponse = new FtpCodeResponse(FtpStatusCodes.Code502, "Command not implemented.");
                }

                return _notImplementedCommandResponse;
            }
        }

    }
}
